<template>
    <div class="layout-content">
        <div class="layout-content-main">
            <div class="content-div">
                <Row style="margin-bottom:5px;">
                    <Col span="21"
                         class="table-form-input-select-col">
                    <span class="alltitle">项目管理</span>
                    </Col>
                    <Col span="3"
                         class="table-form-input-select-col"
                         order="4">
                    <Button type="primary"
                            icon="ios-book"
                            size="large"
                            @click="addData">新增项目</Button>
                    </Col>
                    <!--  <Col span="2" class="table-form-input-select-col" order="4">
                   <Button type="error" icon="ios-trash" size="large" @click="deleteall">删除</Button>
                   </Col> -->
                </Row>
            </div>
            <!--    <hr class="hr1" /> -->
            <div class="content-div">
                <Table border
                       :columns="columns2"
                       :data="data"
                       ref="table"
                       @on-selection-change="selectChange"></Table>
            </div>
        </div>
        <Modal v-model="addDataModalFlag"
               title="新增项目"
               @on-ok="handleSubmit('formValidate')"
               :mask-closable="false">
            <Form :label-width="120"
                  ref="formValidate"
                  :rules="ruleValidate"
                  :model="formValidate">
                <FormItem label="项目编号"
                          prop="code">
                    <Input placeholder="输入项目编号"
                           class="input-select-class"
                           v-model="formValidate.code"></Input>
                </FormItem>
                <FormItem label="项目名称"
                          prop="name">
                    <Input placeholder="输入项目名称"
                           class="input-select-class"
                           v-model="formValidate.name"></Input>
                </FormItem>
                <FormItem label="管理版块"
                          prop="name">
                    <Row>
                      <Col span="12">
                          <RadioGroup v-model="formValidate.type">
                              <Radio label="1"><span>事界简易版</span></Radio><br>
                              <Radio label="2"><span>事界基础版</span></Radio><br>
                              <Radio label="3"><span>事界高级A版</span></Radio><br>
                              <Radio label="4"><span>事界高级B&云平台</span></Radio>
                          </RadioGroup>
                      </Col>
                      <Col span="12">
                          <Col span="12">
                          <span>预备员工专区</span>
                          </Col>
                          <Col>
                          <i-switch v-model="formValidate.reservestaff" :true-value="'1'" :false-value="'0'">
                              <span slot="open">开</span>
                              <span slot="close">关</span>
                          </i-switch>
                          </Col>
                          <Col span="12">
                          <span>51问卷</span>
                          </Col>
                          <Col>
                          <i-switch v-model="formValidate.questionnaire" :true-value="'1'" :false-value="'0'">
                              <span slot="open">开</span>
                              <span slot="close">关</span>
                          </i-switch>
                          </Col>
                      </Col>
                    </Row>
                </FormItem>
                <FormItem label="年份"
                          prop="year">
                    <Select class="input-select-class"
                            value="2019"
                            v-model="formValidate.year">
                        <Option value="2019">2019</Option>
                        <Option value="2020">2020</Option>
                        <Option value="2020">2021</Option>
                        <Option value="2020">2022</Option>
                        <Option value="2020">2023</Option>
                        <Option value="2020">2024</Option>
                        <Option value="2020">2025</Option>
                        <Option value="2020">2026</Option>
                        <Option value="2020">2027</Option>
                    </Select>
                </FormItem>
                <FormItem label="执行人"
                          prop="operate_name">
                    <Input placeholder="输入执行人"
                           class="input-select-class"
                           v-model="formValidate.operate_name"
                           @on-blur="douser"></Input>
                </FormItem>
                <FormItem label="主管">
                    <Input v-if="sname"
                           placeholder=""
                           class="input-select-class"
                           v-model="sname"
                           disabled></Input>
                </FormItem>
                <FormItem label="协同人员一">
                    <Input placeholder="输入协同人员一"
                           class="input-select-class"
                           v-model="formValidate.teamwork1_name"
                           @on-blur="dtuser1"></Input>
                </FormItem>
                <FormItem label="协同人员管理版块">
                    <Row>
                      <Col span="12">
                          <RadioGroup v-model="formValidate.type1">
                              <Radio label="0"><span>无</span></Radio><br>
                              <Radio label="1"><span>事界简易版</span></Radio><br>
                              <Radio label="2"><span>事界基础版</span></Radio><br>
                              <Radio label="3"><span>事界高级A版</span></Radio><br>
                              <Radio label="4"><span>事界高级B&云平台</span></Radio>
                          </RadioGroup>
                      </Col>
                      <Col span="12">
                          <Col span="12">
                          <span>预备员工专区</span>
                          </Col>
                          <Col>
                          <i-switch v-model="formValidate.reservestaff1" :true-value="'1'" :false-value="'0'">
                              <span slot="open">开</span>
                              <span slot="close">关</span>
                          </i-switch>
                          </Col>
                          <Col span="12">
                          <span>51问卷</span>
                          </Col>
                          <Col>
                          <i-switch v-model="formValidate.questionnaire1" :true-value="'1'" :false-value="'0'">
                              <span slot="open">开</span>
                              <span slot="close">关</span>
                          </i-switch>
                          </Col>
                      </Col>
                    </Row>
                </FormItem>
                <FormItem label="协同人员二">
                    <Input placeholder="输入协同人员二"
                           class="input-select-class"
                           v-model="formValidate.teamwork2_name"
                           @on-blur="dtuser2"></Input>
                </FormItem>
                <FormItem label="协同人员管理版块">
                    <Row>
                      <Col span="12">
                          <RadioGroup v-model="formValidate.type2">
                              <Radio label="0"><span>无</span></Radio><br>
                              <Radio label="1"><span>事界简易版</span></Radio><br>
                              <Radio label="2"><span>事界基础版</span></Radio><br>
                              <Radio label="3"><span>事界高级A版</span></Radio><br>
                              <Radio label="4"><span>事界高级B&云平台</span></Radio>
                          </RadioGroup>
                      </Col>
                      <Col span="12">
                          <Col span="12">
                          <span>预备员工专区</span>
                          </Col>
                          <Col>
                          <i-switch v-model="formValidate.reservestaff2" :true-value="'1'" :false-value="'0'">
                              <span slot="open">开</span>
                              <span slot="close">关</span>
                          </i-switch>
                          </Col>
                          <Col span="12">
                          <span>51问卷</span>
                          </Col>
                          <Col>
                          <i-switch v-model="formValidate.questionnaire2" :true-value="'1'" :false-value="'0'">
                              <span slot="open">开</span>
                              <span slot="close">关</span>
                          </i-switch>
                          </Col>
                      </Col>
                    </Row>
                </FormItem>
                <FormItem label="有效期">
                    <Input placeholder=""
                           class="input-select-class"
                           v-model="formValidate.valid2"></Input>
                </FormItem>
            </Form>
        </Modal>
        <Modal v-model="showDataModalFlag"
               title="修改项目"
               @on-ok="handleSubmit2('formValidate2')"
               :mask-closable="false">
            <Form :label-width="120"
                  ref="formValidate2"
                  :rules="ruleValidate2"
                  :model="showDataModalObject">
                <FormItem label="项目编号"
                          prop="code">
                    <Input placeholder="输入项目编号"
                           class="input-select-class"
                           v-model="showDataModalObject.code"></Input>
                </FormItem>
                <FormItem label="项目名称"
                          prop="name">
                    <Input placeholder="输入项目名称"
                           class="input-select-class"
                           v-model="showDataModalObject.name"></Input>
                </FormItem>
                <FormItem label="管理版块"
                          prop="name">
                    <Row>
                      <Col span="12">
                          <RadioGroup v-model="showDataModalObject.type">
                              <Radio label="1"><span>事界简易版</span></Radio><br>
                              <Radio label="2"><span>事界基础版</span></Radio><br>
                              <Radio label="3"><span>事界高级A版</span></Radio><br>
                              <Radio label="4"><span>事界高级B&云平台</span></Radio>
                          </RadioGroup>
                      </Col>
                      <Col span="12">
                          <Col span="12">
                          <span>预备员工专区</span>
                          </Col>
                          <Col>
                          <i-switch v-model="showDataModalObject.reservestaff" :true-value="'1'" :false-value="'0'">
                              <span slot="open">开</span>
                              <span slot="close">关</span>
                          </i-switch>
                          </Col>
                          <Col span="12">
                          <span>51问卷</span>
                          </Col>
                          <Col>
                          <i-switch v-model="showDataModalObject.questionnaire" :true-value="'1'" :false-value="'0'">
                              <span slot="open">开</span>
                              <span slot="close">关</span>
                          </i-switch>
                          </Col>
                      </Col>
                    </Row>
                </FormItem>
                <FormItem label="年份"
                          prop="year">
                    <Select class="input-select-class"
                            v-model="showDataModalObject.year">
                        <Option value="2019">2019</Option>
                        <Option value="2020">2020</Option>
                        <Option value="2020">2021</Option>
                        <Option value="2020">2022</Option>
                        <Option value="2020">2023</Option>
                        <Option value="2020">2024</Option>
                        <Option value="2020">2025</Option>
                        <Option value="2020">2026</Option>
                        <Option value="2020">2027</Option>
                    </Select>
                </FormItem>
                <FormItem label="执行人"
                          prop="operate_name2">
                    <Input placeholder="输入执行人"
                           class="input-select-class"
                           v-model="showDataModalObject.operate_name"
                           @on-blur="douser2"></Input>
                </FormItem>
                <FormItem label="主管">
                    <Input placeholder=""
                           class="input-select-class"
                           v-model="showDataModalObject.supervisor_name"
                           disabled></Input>
                </FormItem>
                <FormItem label="协同人员一">
                    <Input placeholder="输入协同人员一"
                           class="input-select-class"
                           v-model="showDataModalObject.teamwork1_name"
                           @on-blur="dtuser12"></Input>
                </FormItem>
                <FormItem label="协同人员管理版块">
                    <Row>
                      <Col span="12">
                          <RadioGroup v-model="showDataModalObject.type1">
                              <Radio label="0"><span>无</span></Radio><br>
                              <Radio label="1"><span>事界简易版</span></Radio><br>
                              <Radio label="2"><span>事界基础版</span></Radio><br>
                              <Radio label="3"><span>事界高级A版</span></Radio><br>
                              <Radio label="4"><span>事界高级B&云平台</span></Radio>
                          </RadioGroup>
                      </Col>
                      <Col span="12">
                          <Col span="12">
                          <span>预备员工专区</span>
                          </Col>
                          <Col>
                          <i-switch v-model="showDataModalObject.reservestaff1" :true-value="'1'" :false-value="'0'">
                              <span slot="open">开</span>
                              <span slot="close">关</span>
                          </i-switch>
                          </Col>
                          <Col span="12">
                          <span>51问卷</span>
                          </Col>
                          <Col>
                          <i-switch v-model="showDataModalObject.questionnaire1" :true-value="'1'" :false-value="'0'">
                              <span slot="open">开</span>
                              <span slot="close">关</span>
                          </i-switch>
                          </Col>
                      </Col>
                    </Row>
                </FormItem>
                <FormItem label="协同人员二">
                    <Input placeholder="输入协同人员二"
                           class="input-select-class"
                           v-model="showDataModalObject.teamwork2_name"
                           @on-blur="dtuser22"></Input>
                </FormItem>
                <FormItem label="协同人员管理版块">
                    <Row>
                      <Col span="12">
                          <RadioGroup v-model="showDataModalObject.type2">
                              <Radio label="0"><span>无</span></Radio><br>
                              <Radio label="1"><span>事界简易版</span></Radio><br>
                              <Radio label="2"><span>事界基础版</span></Radio><br>
                              <Radio label="3"><span>事界高级A版</span></Radio><br>
                              <Radio label="4"><span>事界高级B&云平台</span></Radio>
                          </RadioGroup>
                      </Col>
                      <Col span="12">
                          <Col span="12">
                          <span>预备员工专区</span>
                          </Col>
                          <Col>
                          <i-switch v-model="showDataModalObject.reservestaff2" :true-value="'1'" :false-value="'0'">
                              <span slot="open">开</span>
                              <span slot="close">关</span>
                          </i-switch>
                          </Col>
                          <Col span="12">
                          <span>51问卷</span>
                          </Col>
                          <Col>
                          <i-switch v-model="showDataModalObject.questionnaire2" :true-value="'1'" :false-value="'0'">
                              <span slot="open">开</span>
                              <span slot="close">关</span>
                          </i-switch>
                          </Col>
                      </Col>
                    </Row>
                </FormItem>
                <FormItem label="有效期">
                    <Input placeholder=""
                           class="input-select-class"
                           v-model="showDataModalObject.valid2"></Input>
                </FormItem>
            </Form>
        </Modal>
    </div>
</template>
<script>
export default {
    data() {
        return {
            oid: "",
            tw1id: "",
            tw2id: "",
            tw1name: "",
            tw2name: "",
            sid: "",
            sname: "",
            formValidate: {
                code: "",
                name: "",
                year: "",
                operate_name: "",
                supervisor_name: "",
                valid2: "",
                type: "3"
            },
            ruleValidate: {
                name: [
                    {
                        required: true,
                        message: "项目名不能为空",
                        trigger: "blur"
                    }
                ],
                code: [
                    {
                        required: true,
                        message: "项目编号不能为空",
                        trigger: "blur"
                    }
                ],
                year: [
                    {
                        required: true,
                        message: "年份不能为空",
                        trigger: "blur"
                    }
                ],
                operate_name: [
                    {
                        required: true,
                        message: "操作人不能为空",
                        trigger: "blur"
                    }
                ]
            },
            formValidate2: {
                code: "",
                name: "",
                year: "",
                operate_name: "",
                supervisor_name: "",
                valid2: "",
                type: ""
            },
            ruleValidate2: {
                name: [
                    {
                        required: true,
                        message: "项目名不能为空",
                        trigger: "blur"
                    }
                ],
                code: [
                    {
                        required: true,
                        message: "项目编号不能为空",
                        trigger: "blur"
                    }
                ],
                year: [
                    {
                        required: true,
                        message: "年份不能为空",
                        trigger: "blur"
                    }
                ],
                operate_name: [
                    {
                        required: true,
                        message: "操作人不能为空",
                        trigger: "blur"
                    }
                ]
            },
            showDataModalObject: {},
            addDataModalObject: {},
            showDataModalFlag: false,
            addDataModalFlag: false,

            columns2: [
                {
                    title: "序号",
                    key: "id",
                    width: 80,
                    type: "selection",
                    sortType: "asc"
                },
                {
                    title: "项目编号",
                    key: "code"
                },
                {
                    title: "项目名称",
                    key: "name"
                },
                {
                    title: "年份",
                    key: "year",
                    width: 100
                },
                {
                    title: "执行人",
                    key: "operate_name",
                    width: 100
                },
                {
                    title: "主管",
                    key: "supervisor_name",
                    width: 100
                },
                {
                    title: "有效期",
                    key: "valid",
                    width: 200
                },
                {
                    title: "操作",
                    key: "action",
                    width: 200,
                    render: (h, params) => {
                        return h("div", [
                            h(
                                "Button",
                                {
                                    props: {
                                        type: "info",
                                        size: "small"
                                    },
                                    style: {
                                        marginRight: "5px"
                                    },
                                    on: {
                                        click: () => {
                                            this.showData(params.index);
                                        }
                                    }
                                },
                                "编辑"
                            )
                        ]);
                    }
                }
            ],
            data: [],
            pageData: {
                current: 1,
                total: 0,
                pageSize: 20
            }
        };
    },
    created() {
        var self = this;
        $.ajax({
            url:
                "https://evp.51job.com/51job/api/51miniadmin/back.php?action=projectlist",
            type: "POST",
            dataType: "json",
            success: function(data) {
                console.log(data);

                if (data.data != null) {
                    self.data = data.data;
                    self.pageData.total = parseInt(data.datatotal);
                    self.pageData.pageSize = 20;
                    self.current = 1;
                } else {
                    self.$Message.error("没有项目");
                }
            }
        });
    },
    methods: {
        changepage(currentPage) {
            if (isNaN(currentPage)) {
                currentPage = 1;
            }
            var self = this;
            /*self.$api.get('/api/v1/table_data', null, function (result) {
                      self.data = result.resultData.dataList
                      self.pageData = result.resultData.pageData
                    })*/
            var searchdata = {};

            console.log(searchdata);

            $.ajax({
                url:
                    "https://evp.51job.com/51job/api/51miniadmin/back.php?action=projectlist",
                type: "POST",
                dataType: "json",
                success: function(data) {
                    console.log(data);

                    if (data.data != null) {
                        self.data = data.data;
                        self.pageData.total = parseInt(data.datatotal);
                        self.pageData.pageSize = 20;
                        self.current = currentPage;
                    } else {
                        self.$Message.error("没有项目");
                    }
                }
            });
        },
        douser() {
            var self = this;
            console.log(this.formValidate.operate_name);

            $.ajax({
                url:
                    "https://evp.51job.com/51job/api/51miniadmin/back.php?action=snamefromoname",
                data: {
                    name: self.formValidate.operate_name
                },
                type: "POST",
                dataType: "json",
                success: function(data) {
                    console.log(data);
                    if (data.data == null) {
                        self.$Message.error("没有此操作人");
                    } else {
                        self.sname = data.data.supervisor_name;
                        self.oid = data.data.operate_id;
                        self.sid = data.data.supervisor_id;
                        console.log(self.sname);
                    }
                }
            });
        },
        douser2() {
            var self = this;
            console.log(self.showDataModalObject.operate_name);

            $.ajax({
                url:
                    "https://evp.51job.com/51job/api/51miniadmin/back.php?action=snamefromoname",
                data: {
                    name: self.showDataModalObject.operate_name
                },
                type: "POST",
                dataType: "json",
                success: function(data) {
                    console.log(data);
                    if (data.data == null) {
                        self.$Message.error("没有此操作人");
                    } else {
                        self.sname = data.data.supervisor_name;
                        self.oid = data.data.operate_id;
                        self.sid = data.data.supervisor_id;
                        self.showDataModalObject.supervisor_name = self.sname;
                        console.log(self.sname);
                    }
                }
            });
        },
        dtuser1() {
            var self = this;
            console.log(this.formValidate.teamwork1_name);

            $.ajax({
                url:
                    "https://evp.51job.com/51job/api/51miniadmin/back.php?action=idfromname",
                data: {
                    name: self.formValidate.teamwork1_name
                },
                type: "POST",
                dataType: "json",
                success: function(data) {
                    console.log(data);
                    if (data.data == null) {
                        self.$Message.error("没有此客户帐号");
                    } else {
                        self.tw1id = data.data.id;
                        console.log(self.tw1id);
                    }
                }
            });
        },
        dtuser2() {
            var self = this;
            console.log(this.formValidate.teamwork2_name);

            $.ajax({
                url:
                    "https://evp.51job.com/51job/api/51miniadmin/back.php?action=idfromname",
                data: {
                    name: self.formValidate.teamwork2_name
                },
                type: "POST",
                dataType: "json",
                success: function(data) {
                    console.log(data);
                    if (data.data == null) {
                        self.$Message.error("没有此客户帐号");
                    } else {
                        self.tw2id = data.data.id;
                        console.log(self.tw2id);
                    }
                }
            });
        },
        dtuser12() {
            var self = this;
            console.log(this.formValidate.teamwork1_name);

            $.ajax({
                url:
                    "https://evp.51job.com/51job/api/51miniadmin/back.php?action=idfromname",
                data: {
                    name: self.showDataModalObject.teamwork1_name
                },
                type: "POST",
                dataType: "json",
                success: function(data) {
                    console.log(data);
                    if (data.data == null) {
                        self.$Message.error("没有此客户帐号");
                    } else {
                        self.tw1id = data.data.id;
                        console.log(self.tw1id);
                    }
                }
            });
        },
        dtuser22() {
            var self = this;
            console.log(this.formValidate.teamwork2_name);

            $.ajax({
                url:
                    "https://evp.51job.com/51job/api/51miniadmin/back.php?action=idfromname",
                data: {
                    name: self.showDataModalObject.teamwork2_name
                },
                type: "POST",
                dataType: "json",
                success: function(data) {
                    console.log(data);
                    if (data.data == null) {
                        self.$Message.error("没有此客户帐号");
                    } else {
                        self.tw2id = data.data.id;
                        console.log(self.tw2id);
                    }
                }
            });
        },
        showData(index) {
            var self = this;
            self.showDataModalFlag = true;
            self.showDataModalObject = self.data[index];
            console.log(self.showDataModalObject);
        },
        addData(index) {
            var self = this;
            self.addDataModalFlag = true;
            //self.addDataModalObject = self.data[index]
        },
        changeDate(dateA) {
            var dateee = new Date(dateA).toJSON();

            var date = new Date(+new Date(dateee) + 8 * 3600 * 1000)
                .toISOString()
                .replace(/T/g, " ")
                .replace(/\.[\d]{3}Z/, "");

            return date;
        },
        handleSubmit(name) {
            this.$refs[name].validate(valid => {
                if (valid) {
                    var self = this;

                    $.ajax({
                        url:
                            "https://evp.51job.com/51job/api/51miniadmin/back.php?action=projectcreate",
                        data: {
                            code: self.formValidate.code,
                            name: self.formValidate.name,
                            year: self.formValidate.year,
                            operate_id: self.oid,
                            supervisor_id: self.sid,
                            valid: self.formValidate.valid2,
                            type: self.formValidate.type,
                            reservestaff: self.formValidate.reservestaff,
                            questionnaire: self.formValidate.questionnaire,
                            teamwork1_id: self.tw1id,
                            type1: self.formValidate.type1,
                            reservestaff1: self.formValidate.reservestaff1,
                            questionnaire1: self.formValidate.questionnaire1,
                            teamwork2_id: self.tw2id,
                            type2: self.formValidate.type2,
                            reservestaff2: self.formValidate.reservestaff2,
                            questionnaire2: self.formValidate.questionnaire2,
                            end: ''
                        },
                        type: "POST",
                        dataType: "json",
                        success: function(data) {
                            if (data.code == 1001) {
                                self.$Message.error("项目编号已经存在!");
                            }
                            if (data.code == 1) {
                                console.log(data);
                                self.$router.push({
                                    path: "/项目管理"
                                });
                                self.$Message.success("提交成功!");
                                self.changepage(1);
                            }
                        }
                    });
                } else {
                    this.$Message.error("表单验证失败!");
                }
            });
        },

        handleSubmit2(name) {
            this.$refs[name].validate(valid => {
                if (valid) {
                    var self = this;
                    console.log(self.showDataModalObject.operate_id);
                    console.log(self.showDataModalObject.valid2);
                    if (self.oid == "") {
                        self.oid = self.showDataModalObject.operate_id;
                    }
                    if (self.sid == "") {
                        self.sid = self.showDataModalObject.supervisor_id;
                    }
                    if (self.tw1id == "") {
                        self.tw1id = self.showDataModalObject.teamwork1_id;
                    }
                    if (self.tw2id == "") {
                        self.tw2id = self.showDataModalObject.teamwork2_id;
                    }
                    $.ajax({
                        url:
                            "https://evp.51job.com/51job/api/51miniadmin/back.php?action=projectedit&id=" +
                            self.showDataModalObject.id,
                        data: {
                            code: self.showDataModalObject.code,
                            name: self.showDataModalObject.name,
                            year: self.showDataModalObject.year,
                            operate_id: self.oid,
                            supervisor_id: self.sid,
                            valid: self.showDataModalObject.valid2,
                            type: self.showDataModalObject.type,
                            reservestaff: self.showDataModalObject.reservestaff,
                            questionnaire: self.showDataModalObject.questionnaire,
                            teamwork1_id: self.tw1id,
                            type1: self.showDataModalObject.type1,
                            reservestaff1: self.showDataModalObject.reservestaff1,
                            questionnaire1: self.showDataModalObject.questionnaire1,
                            teamwork2_id: self.tw2id,
                            type2: self.showDataModalObject.type2,
                            reservestaff2: self.showDataModalObject.reservestaff2,
                            questionnaire2: self.showDataModalObject.questionnaire2,
                            end: ''
                        },
                        type: "POST",
                        dataType: "json",
                        success: function(data) {
                            if (data.code == 1001) {
                                self.$Message.error("项目编号已经存在!");
                            }
                            if (data.code == 1) {
                                console.log(data);
                                self.$router.push({
                                    path: "/项目管理"
                                });
                                self.$Message.success("提交成功!");
                                self.changepage(1);
                            }
                        }
                    });
                } else {
                    this.$Message.error("表单验证失败!");
                }
            });
        },

        removeData(index) {
            var self = this;
            self.$api.post("/api/v1/edit", self.data[index], function(result) {
                self.data.splice(index, 1);
                self.$Message.info(result.message);
            });
        },
        exportData(type) {
            this.$refs.table.exportCsv({
                filename: "The original data"
            });
        },
        selectChange(selection, index) {
            this.multipleSelection = selection;
        },
        deleteall() {
            //console.log(this.multipleSelection);
            if (this.multipleSelection == null) {
                this.$Message.error("请至少勾选一项");
            } else {
                this.$Modal.confirm({
                    title: "确认删除？",
                    content: "",
                    onOk: () => {
                        var arr = this.multipleSelection;
                        console.log(arr);
                        var self = this;
                        self.$api.post("/api/v1/edit", self.data, function(
                            result
                        ) {
                            let add = self.data.filter(
                                item => !arr.some(ele => ele.id === item.id)
                            );
                            self.data = add;

                            var jobarr = [];
                            for (var i = 0; i < arr.length; i++) {
                                jobarr.push(arr[i].id);
                            }
                            console.log(jobarr);
                            $.ajax({
                                url:
                                    "http://evp.51job.com/51job/api/51jobtrain/back_api.php?action=delad",
                                data: {
                                    "id[]": jobarr
                                },
                                type: "POST",
                                dataType: "json",
                                success: function(data) {
                                    console.log(data);
                                    self.changepage(1);
                                }
                            });
                        });
                    },
                    onCancel: () => {
                        this.$Message.info("取消删除");
                    }
                });
            }
        }
    }
};
</script>
